var a = require("../../../@babel/runtime/helpers/toConsumableArray"), t = getApp();

Page({
    data: {
        indexBannerImg: "",
        indexBannerPage: "",
        listData: [],
        searchText: "",
        isLoadMore: !0,
        total_page: 0,
        page: 1
    },
    onLoad: function(a) {
        this.getIndexData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    bindBanner: function() {
        wx.navigateTo({
            url: this.data.indexBannerPage
        });
    },
    _getMoreData: function() {
        var e = this;
        if (!(this.data.page >= this.data.total_page)) {
            this.data.isLoadMore = !1;
            var n = t.getNetAddresss("plugin.health-assessment.api.index.getData");
            this.data.page++;
            var s = {
                art: "index"
            };
            s.page = this.data.page, "" != this.data.searchText && (s.keyword = this.data.searchText), 
            t._postNetWork({
                url: n,
                showToastIn: !0,
                maskIn: !1,
                data: s,
                success: function(t) {
                    var n = t.data;
                    if (1 == n.result) {
                        e.data.isLoadMore = !0;
                        var s = n.data.index, o = e.data.listData;
                        o.push.apply(o, a(s.health.data)), e.setData({
                            listData: o
                        }), s.health.current_page >= s.health.last_page && (e.data.isLoadMore = !1);
                    }
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        }
    },
    onShareAppMessage: function() {},
    gotoRecord: function() {
        wx.navigateTo({
            url: "/packageE/healthy/healthyRecord/healthyRecord"
        });
    },
    gotoHealthyEv: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageE/healthy/healthyEv/healthyEv?health_id=" + t
        });
    },
    searchHealthy: function(a) {
        var t = a.detail.value;
        t != this.data.searchText && (this.data.searchText = t, this.getIndexData(t));
    },
    getIndexData: function() {
        var a = this, e = t.getNetAddresss("plugin.health-assessment.api.index.getData"), n = {
            art: "index"
        };
        "" != this.data.searchText && (n.keyword = this.data.searchText), this.data.isLoadMore = !1, 
        this.data.page = 1, t._postNetWork({
            url: e,
            showToastIn: !0,
            maskIn: !1,
            data: n,
            success: function(t) {
                var e = t.data;
                if (1 == e.result) {
                    a.data.isLoadMore = !0;
                    var n = e.data.index;
                    a.setData({
                        indexBannerImg: n.banner.health_banner,
                        indexBannerPage: n.banner.health_banner_small,
                        listData: n.health.data
                    }), a.data.total_page = n.health.last_page, n.health.current_page >= n.health.last_page && (a.data.isLoadMore = !1), 
                    console.log(n.health.data);
                }
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    }
});